<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        #goodsList {
            width: 1300px;
            height: 500px;
            border: 2px red solid;
            margin: 0 auto;
            margin-top: 50px;
        }

        #goodsList .item {
            width: 234px;
            height: 300px;
            margin: 10px;
            border: 2px solid red;
            text-align: center;
            float: left;
        }

        .item img {
            width: 80%;
        }

        .item .detail {
            font-size: 14px;
            color: #333;
            margin-top: 10px;
            margin-bottom: 12px;
        }

        .item .price {
            color: #ff6700;
        }
    </style>
</head>

<body>
    <div id="goodsList">

    </div>
</body>
<script>
    var data = [
        {
            name: "黑鲨1",
            detail: "磁动力升降肩键",
            price: "2699",
            imgurl: "https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/7290b681343512c60e3a845379f3335f.jpg?thumb=1&w=350&h=350&f=webp&q=90"
        },
        {
            name: "黑鲨2",
            detail: "磁动力升降肩键",
            price: "2699",
            imgurl: "https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/7290b681343512c60e3a845379f3335f.jpg?thumb=1&w=350&h=350&f=webp&q=90"

        },
        {
            name: "黑鲨3",
            detail: "磁动力升降肩键",
            price: "2699",
            imgurl:"https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/c5c752522100ecd364cc53752bb660bc.jpg?thumb=1&w=350&h=350&f=webp&q=90"

        },
        {
            name: "黑鲨4",
            detail: "磁动力升降肩键",
            price: "2699",
            imgurl: "https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/7290b681343512c60e3a845379f3335f.jpg?thumb=1&w=350&h=350&f=webp&q=90"

        },
        {
            name: "黑鲨5",
            detail: "磁动力升降肩键",
            price: "2699",
            imgurl: "https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/7290b681343512c60e3a845379f3335f.jpg?thumb=1&w=350&h=350&f=webp&q=90"

        }

    ]



    var str = "";



    for (var i = 0; i < data.length; i++) {
        str += `
            <div class="item">
                <img src="${data[i].imgurl}" alt="">
                <h4>${data[i].name}</h4>
                <p class="detail">${data[i].detail}</p>
                <p class="price">${data[i].price}元起</p>
            </div>   
        `;
    }

    var gs = document.getElementById("goodsList");
    // console.log(gs);
    gs.innerHTML = str;

</script>

</html>